<?php
sql2();
function pfindthread($id){
$cmd="SELECT * FROM `thread` WHERE threadid=".$id;
return mysql_fetch_assoc(mysql_query($cmd));
}

function pfinduser($id){
$cmd="SELECT * FROM `user` WHERE userid=".$id;
return mysql_fetch_assoc(mysql_query($cmd));
}

if (isset($_GET['ok']))
{
 $cmd="UPDATE `user` SET user_ok=1 WHERE userid=".$_GET['ok'];
 mysql_query($cmd);
}
if (isset($_GET['del']))
{
 $cmd="DELETE FROM `post` WHERE postid=".$_GET['del'];
 mysql_query($cmd);
}
if (isset($_GET['delt']))
{
 $cmd="DELETE FROM `thread` WHERE threadid=".$_GET['delt'];
 mysql_query($cmd);
}
 echo '<table width="775" border="1" class="viewmd" cellpadding="10" cellspacing="0">
  <th width="70px">Poster</th>
  <th width="160px">Chủ đề</th>
  <th>Nội dung</th>
  <th width="60px">Thời gian</th>
  <th width="60px">Tình trạng</th>
  <th width="40px">Xóa</th>';
	  $sql="SELECT * FROM `post` ORDER BY postid DESC LIMIT 0,500";
	  $excute=mysql_query($sql);
	  while ($info=mysql_fetch_array($excute,MYSQL_ASSOC))
	  {
	  $user=pfinduser($info['userid']);
	  $thread=pfindthread($info['threadid']);
	      echo'<tr>';
		  echo '<td>'.$user['username'].'</td>'; 
		  echo '<td>'.readmore($thread['title'],5);

		  echo'</td>';
		  echo '<td><a target="_blank" href="http://diendan.cailuongso.com/showthread.php?t='.$info['threadid'].'&p='.$info['postid'].'#post'.$info['postid'].'">'.wordwrap(substr($info['pagetext'],0,45),50,"<br/>\n").'</a></td>';
		  echo '<td>'.changetime($info['dateline']).'</td>';
		  echo '<td>';
		  ($user['user_ok']==1)?$duyet='Đã duyệt':$duyet='<div class="buttons"><a class="button save" href="http://beta.cailuongso.com/mem/index.php?menu=poster&ok='.$info['userid'].'">Duyệt</a></div>';
		  echo $duyet; 
		  echo'</td>';
echo '<td><div class="buttons"><a class="button delete" href="http://beta.cailuongso.com/mem/index.php?menu=poster&del='.$info['postid'].'">Xóa</a></div></td></tr>';
	  } 
	  echo '</table>';
sql();
?>


